﻿package com.qy.db;

import com.qy.db.pool.DBPoolMgr;
import com.qy.util.LogUtil;
import com.qy.util.TimeUtil;

public class DbWatch {

	private long first = 0;
	private long second = 0;

	public DbWatch() {
		first = TimeUtil.getSysCurTimeMillis();
	}

	public void getPool() {
		second = TimeUtil.getSysCurTimeMillis();
	}

	public void commit(String procName) {
		long end = TimeUtil.getSysCurTimeMillis();		
		long spendTime = end - first;
		if (spendTime > 1000) {
			LogUtil.error(String.format("执行语句%s花耗时间总时间 超过:%sms,获取连接：%sms,执行sql:%sms", procName, spendTime, second - first, end - second));
			LogUtil.error(",Strategy Pool:"+DBPoolMgr.getStrategyPoolState());			
		}
	}
}
